from flask import Flask, render_template, url_for
from flask_bootstrap import Bootstrap5
from flask_moment import Moment
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import DataRequired, Length
from datetime import datetime

app = Flask(__name__)
bootstrap = Bootstrap5(app)
moment = Moment(app)
app.secret_key = 'dev'

class LoginForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired(), Length(1, 20)])
    password = PasswordField('Password', validators=[DataRequired(), Length(8, 150)])
    remember = BooleanField('Remember me')
    submit = SubmitField()


@app.route('/')
@app.route('/index')
def index():
    form = LoginForm()
    return render_template('index.html', form = form, current_time=datetime.now())

@app.route('/name/')
@app.route('/name/<name>')
def user(name=None):
    return render_template('user.html', name=name)